﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Infrastructure.Web.Extensions;
using Microsoft.Practices.Unity;
using Skynet.BusinessLogic.BusinessComponents;
using Skynet.WebFoundation.Services.Session;
using System.Web.Routing;
using System.Collections; 
namespace Skynet.WebFoundation.Views
{
    public class Page : Infrastructure.Web.Views.Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            var container = HttpContext.Current.Application.GetContainer();
            var auth = container.Resolve<IBCSecurityQueries>();
            var session = container.Resolve<ISessionService>();
            if (this.RouteData.DataTokens["RouteName"] != null && !auth.Validate(session.ApplicationName, this.RouteData.DataTokens["RouteName"].ToString(), this.User))
                throw new HttpException(403, "Access is denied");
        }       
    }
}
